package com.ysl.study.designpattern.createmode.simplefactory;

import com.ysl.study.designpattern.createmode.abstractfactory.AbstractFactory;

/**
 * 颜色工厂
 *
 * @author yangshanlin
 * @date 2023/2/17 15:15
 * @describe
 */
public class ColorFactory extends AbstractFactory {

    /**
     * 简单工厂
     * @param type
     * @return
     */
    public Color getColor(String type) {
        Color color = null;
        if (type.equals("red")){
            color = new Red();
        } else if (type.equals("green")){
            color = new Green();
        }

        return color;
    }

    /**
     * 抽象工厂
     * @param type
     * @return
     */
    @Override
    public Shape getShapeFactory(String type) {
        return null;
    }

    @Override
    public Color getColorFactory(String type) {
        return getColor(type);
    }
}
